package com.gdust.gkyx.product.controller;

import com.gdust.gkyx.common.result.Result;
import com.gdust.gkyx.product.service.FileUploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * ClassName: FileUploadController
 * Package: com.gdust.gkyx.product.controller
 * Description:
 *
 * @Author syun
 * @Create 2025/1/25 9:21
 * @Version 1.0
 */
@Api(tags = "文件上传接口")
@RestController
@RequestMapping("admin/product")
@CrossOrigin
public class FileUploadController {
    //注入文件上传服务类
    @Autowired
    private FileUploadService fileUploadService;

    /**
     *  //图片上传的方法
     * @param file 文件对象
     * @return
     */
    @ApiOperation("图片上传")
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file) {
        String url = fileUploadService.uploadFile(file);
        return Result.ok(url);
    }
}
